package top.houry.im.server.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import top.houry.im.server.netty.ImServerNetty;

/**
 * @Desc 抽取公共的需要在SpringBoot加载完毕之后加载的业务
 * @Author houry
 * @Date 2021/3/2 8:48
 **/
@Component
public class ImServerRunner implements ApplicationRunner {

    private ImServerNetty serverNetty;

    @Autowired
    public void setServerNetty(ImServerNetty serverNetty) {
        this.serverNetty = serverNetty;
    }

    @Override
    public void run(ApplicationArguments args) {
        startNetty();
    }

    private void startNetty() {
        new Thread(() -> serverNetty.startNettyServer()).start();
    }


}
